package com.feng.eduservice.controller;


import com.feng.commonutils.R;
import com.feng.commonutils.vo.CourseVo;
import com.feng.eduservice.dto.CourseInfoDto;
import com.feng.eduservice.dto.CourseQuery;
import com.feng.eduservice.entity.EduCourse;
import com.feng.eduservice.service.EduCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 课程 前端控制器
 * </p>
 *
 * @author fengge
 * @since 2023-01-17
 */
@RestController
@RequestMapping("/eduservice/edu-course")
@CrossOrigin
public class EduCourseController {
    @Autowired
    private EduCourseService eduCourseService;
    @PostMapping("addCourseInfo")
    public R addCourseInfo(@RequestBody CourseInfoDto courseInfoDto){
        return eduCourseService.addCourseInfo(courseInfoDto);
    }

    @GetMapping("getCourseInfo/{courseId}")
    public R getCourseInfo(@PathVariable String courseId){
        return eduCourseService.getCourseInfo(courseId);
    }
    @PostMapping("updateCourseInfo")
    public R updateCourseInfo(@RequestBody CourseInfoDto courseInfoDto){
        return eduCourseService.updateCourseInfo(courseInfoDto);
    }
    @GetMapping("getPublishCourseInfo/{id}")
    public R getPublishCourseInfo(@PathVariable String id){
        return eduCourseService.getPublishCourseInfo(id);
    }
    //修改课程状态
    @PostMapping("publishCourse/{id}")
    public R publishCourse(@PathVariable String id){

        return eduCourseService.publishCourse(id);
    }
    @PostMapping("pageCourse/{current}/{limit}")
    public R getCourseList(@PathVariable long current, @PathVariable long limit , @RequestBody(required = false)CourseQuery courseQuery) {
      return eduCourseService.getCourseList(current,limit,courseQuery);
    }
    @DeleteMapping("{courseId}")
    public R deleteCourse(@PathVariable String courseId){
       return eduCourseService.deleteCourse(courseId);
    }
    @GetMapping("getCourseInfos/{courseId}")
    public CourseVo getCourseInfos(@PathVariable String courseId){
        return eduCourseService.getCourseInfos(courseId);
    }
    @PostMapping("updateCourseCount/{courseId}")
    public R updateCourseCount(@PathVariable String courseId){
        return eduCourseService.updateCourseCount(courseId);
    }
}

